﻿namespace DimensionsHelper.LanguageService;

public abstract class AnalysisTreeVisitor
{
    public abstract AnalysisNode? Visit(AnalysisNode node);


    public static AnalysisTreeVisitor GetPositionVisitor(int position)
    {
        return new AnalysisTreePositionVisitor(position);
    }
}


internal class AnalysisTreePositionVisitor(int position) : AnalysisTreeVisitor
{
    public override AnalysisNode? Visit(AnalysisNode node)
    {
        return node.Syntax.Span.Contains(position) ? node : null;
    }
}